<template>
  <div class="dashboard-container">
    <component :is="currentRole" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'
import padDashboard from './pad'
import xrayDashboard from './xray'

export default {
  name: 'Dashboard',
  components: { adminDashboard, editorDashboard, xrayDashboard, padDashboard },
  data() {
    return {
      currentRole: 'adminDashboard'
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    console.log('dashboard')
    console.log(this.roles)
    this.currentRole = 'adminDashboard'
    // console.log(!this.roles.includes('admin'))
    if (this.roles.includes('admin')) {
      console.log('adminDashboard')
      this.currentRole = 'adminDashboard'
      return
    }
    if (this.roles.includes('pad')) {
      console.log('padDashboard')
      this.currentRole = 'padDashboard'
      return
    }
    if (this.roles.includes('editor')) {
      console.log('editorDashboard')
      this.currentRole = 'editorDashboard'
      return
    }
  }
}
</script>
